cc.Class({
    extends: cc.Component,

    properties: {
        m_proMaxLen:{
            default:590,
            type: cc.Integer
        },
        m_progressImg:{
           default:null,
           type: cc.Node    
        },
        x_speed:{
            default:300,
            type:cc.Integer
        }
    },

    // LIFE-CYCLE CALLBACKS:
  
    onLoad () {
       // this.propertiesMaxLen = this.m_progressImg.width;
       this.m_progressIg = false;
    },

    setProgress:function(pro){
        if (pro > 1 || pro <0) {
            return;
        }
        var width = this.m_proMaxLen * pro;
        if (width < this.setWidth) {
            return;
        }
        this.setWidth = this.m_proMaxLen * pro;
        this.m_progressIg = true;
        //this.m_progressImg.width = setWidth;    
    },

    start () {
        this.m_progressImg.width = 0;
    },

    update (dt) {
        if (this.m_progressIg) {
            if (this.m_progressImg.width < this.setWidth) {
                this.m_progressImg.width += dt * this.x_speed;
            }

            if (this.m_progressImg.width >= this.setWidth) {
                this.m_progressImg.width = 592;
                this.m_progressIg = false;
                if (this.finishCallBack != null) {
                    this.finishCallBack();
                }
            }
        }
       
     },
});
